package com.lex.cheeseStrip.ui;

import android.os.Bundle;

import com.dh.cheesestrip.Util.AndroidUtil;
import com.dh.cheesestrip.Util.DateUtil;
import com.lex.cheeseStrip.R;
import com.lex.cheeseStrip.app.BaseAct;
import com.squareup.timessquare.CalendarPickerView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;

import butterknife.BindView;

import static com.squareup.timessquare.CalendarPickerView.SelectionMode;

public class CalendarAct extends BaseAct {

    @BindView(R.id.calendar)
    CalendarPickerView calendarView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calendar);
        init(getActivity());

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.YEAR, 3);

        calendarView.init(new Date(), calendar.getTime()).inMode(SelectionMode.SINGLE);

//        Collection<Date> dates = new ArrayList<>();
//        dates.add(DateUtil.stringToDate("yyyy-MM-dd","2016-11-30"));
//        dates.add(DateUtil.stringToDate("yyyy-MM-dd","2016-12-01"));
//        dates.add(DateUtil.stringToDate("yyyy-MM-dd","2016-12-30"));
//        dates.add(DateUtil.stringToDate("yyyy-MM-dd","2016-12-31"));
//        calendarView.highlightDates(dates);
        calendarView.setOnDateSelectedListener(new CalendarPickerView.OnDateSelectedListener() {
            @Override
            public void onDateSelected(Date date) {
                AndroidUtil.toast(DateUtil.dateToString("yyyy-MM-dd",date));
            }

            @Override
            public void onDateUnselected(Date date) {

            }
        });
    }
}
